package com.imay.live.helper;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.imay.live.Constants;
import com.imay.live.model.FeedModel;

/**
 * Created by chan on 2017/6/1 0001.
 */

public class DymaicsUpdateHelper {

    /**
     * 增加新的动态
     *
     * @param feedModel
     */
    public static void createDynamics(FeedModel feedModel) {
        JSONObject json = (JSONObject) JSON.toJSON(feedModel);
        json.put(Constants.DynamicsUpdate.DYNAMICS_ACTION_KEY, Constants.DynamicsUpdate.ACTION_DYNAMICE_CREATE);
        EventHelper.postDynamicsUpdate(json.toJSONString()); // 动态信息改变
    }

    /**
     * 修改动态
     *
     * @param feedModel
     */
    public static void modifyDynamics(FeedModel feedModel) {
        JSONObject json = (JSONObject) JSON.toJSON(feedModel);
        json.put(Constants.DynamicsUpdate.DYNAMICS_ACTION_KEY, Constants.DynamicsUpdate.ACTION_DYNAMICS_MODIFY);
        EventHelper.postDynamicsUpdate(json.toJSONString()); // 动态信息改变
    }

    /**
     * 话题格子修改
     *
     * @param feedModel
     */
    public static void modifyLabels(FeedModel feedModel) {
        JSONObject json = (JSONObject) JSON.toJSON(feedModel);
        json.put(Constants.DynamicsUpdate.DYNAMICS_ACTION_KEY, Constants.DynamicsUpdate.ACTION_LABELS_MODIFY);
        EventHelper.postDynamicsUpdate(json.toJSONString()); // 动态信息改变
    }

    /**
     * 删除动态
     *
     * @param feedId
     */
    public static void deleteDynamics(int feedId) {
        JSONObject json = new JSONObject();
        json.put("feedId", feedId);
        json.put(Constants.DynamicsUpdate.DYNAMICS_ACTION_KEY, Constants.DynamicsUpdate.ACTION_DYNAMICS_DEL);
        EventHelper.postDynamicsUpdate(json.toJSONString());
    }
}
